home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / src / lib / c / stdlib / labs.c < prev    next >
Encoding:
C/C++ Source or Header  |  1989-03-22  |  1.2 KB  |  48 lines

  1. /* 
  2.  * labs.c --
  3.  *
  4.  *    Contains the source code for the "labs" library procedure.
  5.  *
  6.  * Copyright 1988 Regents of the University of California
  7.  * Permission to use, copy, modify, and distribute this
  8.  * software and its documentation for any purpose and without
  9.  * fee is hereby granted, provided that the above copyright
  10.  * notice appear in all copies.  The University of California
  11.  * makes no representations about the suitability of this
  12.  * software for any purpose.  It is provided "as is" without
  13.  * express or implied warranty.
  14.  */
  15.  
  16. #ifndef lint
  17. static char rcsid[] = "$Header: /sprite/src/lib/c/stdlib/RCS/labs.c,v 1.2 89/03/22 00:47:16 rab Exp $ SPRITE (Berkeley)";
  18. #endif /* not lint */
  19.  
  20. #include <stdlib.h>
  21.  
  22. /*
  23.  *----------------------------------------------------------------------
  24.  *
  25.  * labs --
  26.  *
  27.  *    Compute the absolute value of an integer.
  28.  *
  29.  * Results:
  30.  *    The return value is j, unless j is negative, in which case
  31.  *    the return value is -j.
  32.  *
  33.  * Side effects:
  34.  *    None.
  35.  *
  36.  *----------------------------------------------------------------------
  37.  */
  38.  
  39. long
  40. labs(j)
  41.     long j;            /* Value to take the absolute value of. */
  42. {
  43.     if (j < 0) {
  44.     j = -j;
  45.     }
  46.     return j;
  47. }
  48.